package com.example.chongwushangcheng.enums;

/**
 * 商品拍卖类型枚举
 *
 * @author 芋道源码
 */
public enum ProductAuctionTypeEnum {

    YINGSHI(1, "英式拍卖"),
    HELAN(2, "荷兰式拍卖"),
    YIKOUJIA(3, "一口价");

    /**
     * 类型值
     */
    private final Integer type;
    
    /**
     * 类型名
     */
    private final String name;

    ProductAuctionTypeEnum(Integer type, String name) {
        this.type = type;
        this.name = name;
    }

    public Integer getType() {
        return type;
    }

    public String getName() {
        return name;
    }

    /**
     * 根据类型值获取枚举
     */
    public static ProductAuctionTypeEnum getByType(Integer type) {
        if (type == null) {
            return null;
        }
        for (ProductAuctionTypeEnum typeEnum : values()) {
            if (typeEnum.getType().equals(type)) {
                return typeEnum;
            }
        }
        return null;
    }

    /**
     * 获取所有类型值数组
     */
    public static Integer[] getAllTypeArray() {
        ProductAuctionTypeEnum[] values = values();
        Integer[] array = new Integer[values.length];
        for (int i = 0; i < values.length; i++) {
            array[i] = values[i].getType();
        }
        return array;
    }
} 